import requests
import execjs
import math
url= 'https://match.yuanrenxue.com/api/match/1'
headers={
    'User-Agent':'yuanrenxue.project'
}
cookies={
    'sessionid':'bquwssevq5rtc0csflgoz9axhtlid962'
}
with open('test.js', 'r', encoding='utf-8') as fp:
    jscode = fp.read()
fun=execjs.compile(jscode)
sum_num=0
count=0
for i in range(1,5+1):
    url_index=url.format(page=i)
    m=fun.call('get_m')
    params={
        'page':i,
        'm':m
    }
    response=requests.get(url=url_index,headers=headers,params=params).json()
    print(response)
    for x in response.get('data'):
        sum_num+=x.get('value')
        count+=1
print('所有数相加：',sum_num,'总共有：',count)
print('平均数:',math.ceil(sum_num/count))